<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>

<head>
	<base href="<%=basePath%>">
	<title>Admin Login</title>
	<!-- Bootstrap -->
	<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
	<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
	<link href="assets/styles.css" rel="stylesheet" media="screen">
	<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
	<script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>

<body id="login">
	<div class="container">

		<div class="form-signin">
			<h2 class="form-signin-heading">用户名密码</h2>
			<input id="username" type="text" class="input-block-level" placeholder="用户名">
			<input type="password" type="password" id="password" class="input-block-level " placeholder="密码 ">
			
			<select  id="type" class="form-control" required="required">
				<option value="0">管理员</option>
				<option value="1">幼儿</option>
			</select>
			<br/>
			<button onclick="login()" class="btn btn-large btn-primary" >登录</button>
			<a href="register.jsp">
				<button type="button " class="btn btn-large btn-primary">注册</button>
			</a>
		</div>

	</div>
	<!-- /container -->
	<script src="vendors/jquery-1.9.1.min.js "></script>
	<script src="bootstrap/js/bootstrap.min.js "></script>

	<script>
		function login() {
			var username = $("#username").val();
			var password = $("#password").val();
			var type = $("#type").val();
			if (username == '') {
				alert("用户名为空! ");
				return;
			}
			if (password == '') {
				alert("密码为空！ ");
				return;
			}
			if(type==''){
				alert("类型为空！");
				return;
			}
			
			var params = new Object();
			params.username = username;
			params.password = password;
			params.type= type;
			$.ajax({
				type: "POST",
				url: 'logincontroller/login.htmls',
				data: params,
				async: false,
				cache: false,
				dataType: 'json',
				success: function (data) {
					if(data.code != 200){
						alert(data.errorMessage);
						return;
					}else{
						if(type=='0'){
							window.location.href="manage.jsp";
						}
						if(type =='1'){
							window.location.href="leave.jsp";
						}
					}
				}
			});
		}
	</script>


</body>

</html>